package com.sharker.myproject.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.sharker.myproject.commom.base.CrudService;
import com.sharker.myproject.domain.Role;
import com.sharker.myproject.domain.User;
import com.sharker.myproject.mapper.RoleDao;
import com.sharker.myproject.mapper.UserDao;

@Service
@Transactional(readOnly = true, isolation = Isolation.DEFAULT, transactionManager = "")
public class Userservice extends CrudService<UserDao, User> {

	@Autowired
	private UserDao userDao;

	@Autowired
	private RoleDao roleDao;

	public User getUserByLoginName(String username) {
		return userDao.getUserByName(username);
	}

	public User getUserById(String id) {
		return userDao.getUserById(id);
	}

	public void save(User user) {
		userDao.insert(user);
	}

	public List<Role> findRoles(String username) {
		return roleDao.findRoles(username);
	}

	public List<User> findPage(Page<User> page) {
		return dao.selectAll();
		
	}

}
